package com.ruoyi.system.controller;

import com.ruoyi.system.config.WhiteListConfig;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Set;

@RestController
@RequestMapping("/white-list")
public class WhiteListController {

    @Resource
    private WhiteListConfig whiteListConfig;

    @RequestMapping("/list")
    public ResponseEntity<Set<String>> whiteList(){
        Set<String> members = whiteListConfig.getWhiteList();
        return ResponseEntity.ok(members);
    }

    @RequestMapping("/add")
    public ResponseEntity<String> add(String url){
        whiteListConfig.setWhiteList(url);
        return ResponseEntity.ok("添加成功:" + url);
    }

    @RequestMapping("/remove")
    public ResponseEntity<String> remove(String url){
        whiteListConfig.removeWhiteList(url);
        return ResponseEntity.ok("删除成功:" + url);
    }
}
